home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacWorld 1999 June
/
Macworld (1999-06).dmg
/
Shareware World
/
Info
/
For Developers
/
McSerialnumber 1.2
/
CSerialnumLib.h
next >
Wrap
Text File
|
1999-03-21
|
8KB
|
208 lines
//----------------------------------------------------------------------------
// Filename: CSerialnumLib.h
// Copyright © 1998 Wilfried Bernard. All rights reserved.
//
// See the file "McSerialNumber README" for more details and the licensing
// agreement, etc.
//
// Description: Header to implement encoding/decoding of serial numbers
//
// ATTENTION!
// ----------
// If you incorporate the 68k-library in your application
// allways use the following switches with the Metrowerks IDE:
// 68k Processor: check 4 Byte Ints and 8 Byte Doubles ON
// check Far Data, Far Method Table and Far String Consts ON
//
// INTEL - Win95/98/NT USER
// ------------------------------
// You have to convert all input strings from ANSI-C-STRINGS to PASCAL-STRINGS
// first BEFORE using CalcNameCode and StripSerialNumber!!
// You can use the included converter functions c2pstr or p2cstr
// Both functions are defined global!
//
//
// for questions and comments pls. contact:
// <e-mail> mcwareusa@aol.com or mcwareusa@kagi.com
// <www-page> http://members.aol.com/mcwareusa
//
//----------------------------------------------------------------------------
// Revision History:
// Nov, 08 1998 - 1.1.1 String converters defined global for external use - now documented
// Oct, 07 1998 - 1.1 Intel types conversion added
// Dec, 30 1997 - 1.0 oSWSt first public release
//----------------------------------------------------------------------------
#pragma once
#if __INTEL__ // use for Metrowerks compiler (CW 9 & newer) ONLY!!!
#ifndef _INTELTYPES
typedef unsigned char Boolean;
typedef unsigned char * StringPtr;
typedef const unsigned char * ConstStr31Param; // pascal string
typedef const unsigned char * ConstStr63Param;
#endif
#else
#ifndef __CONDITIONALMACROS__
#include <ConditionalMacros.h>
#endif
#if TARGET_OS_MAC
#ifndef __MACTYPES__
#include <MacTypes.h>
#endif
#endif
#endif
class CSerialnumberLib
{
public:
// all Public Functions
// MANIPULATOR
//----------------------------------------------------------------------------
// PARAMETER: ConstStr31Param first_name ATTENTION: NEEDS to be a PASACAL STRING
// ConstStr31Param last_name ATTENTION: NEEDS to be a PASACAL STRING
//
// RESULT: long long test_number
//
// entering the customer first and a last name creates a 64 bit test number
// which is NOT the real serial number.
// check with the real serialnumber AND your master code with CheckSumTest()
//----------------------------------------------------------------------------
static long long CalcNameCode (ConstStr31Param inFirstNameStr,
ConstStr63Param inLastNameStr);
//----------------------------------------------------------------------------
// PARAMETER: long long test_number
// long long serial_number
// long long master_key
//
// RESULT: Boolean test_valid
//
// checks validity of the real serialnumber by testing against your master code
// and the names test number (CalcNameCode)
//----------------------------------------------------------------------------
static Boolean CheckSumTest (long long inNameCode,
long long inSerialNumber,
long long inMasterKey );
//----------------------------------------------------------------------------
// PARAMETER: ConstStr31Param serial_number_string ATTENTION: NEEDS to be a PASACAL STRING
// long long serial_number
//
// RESULT: Boolean test_valid
//
// converts the serial number string into the real serialnumber,
// strips all non-hexadecimal characters. Reports FALSE if serialnumber
// string is invalid else TRUE
//----------------------------------------------------------------------------
static Boolean StripSerialNumber (ConstStr31Param inSerNrString,
long long& outSum);
// COVERTER
//----------------------------------------------------------------------------
// PARAMETER: IN: StringPtr serial_number_string (p-string)
// OUT: long long serial_number
//
// RESULT: none
//
// converts the serial number pascal-string into the 64 bit number,
//----------------------------------------------------------------------------
static void PStrToLLong (StringPtr inPStr,
long long& outSum);
//----------------------------------------------------------------------------
// PARAMETER: IN: StringPtr serial_number_string (c-string)
// OUT: long long serial_number
//
// RESULT: none
//
// converts the serial number c-string into the 64 bit number,
//----------------------------------------------------------------------------
static void ANSIStrToLLong (char* inCStr,
long long& outVal);
//----------------------------------------------------------------------------
// PARAMETER: OUT: ConstStr31Param serial_number_string (allocate memory!)
// IN: long long IN serial_number
//
// RESULT: none
//
// converts 64 bit number into a serial number pascal-string
//----------------------------------------------------------------------------
static void LLongToPStr (ConstStr31Param outPStr,
long long inSum);
//----------------------------------------------------------------------------
// PARAMETER: OUT: ConstStr31Param serial_number_string (allocate memory!)
// IN: long long serial_number
//
// RESULT: none
//
// converts 64 bit number into a serial number pascal-string
//----------------------------------------------------------------------------
static void LLongToANSIStr (ConstStr31Param outCStr,
long long inVal);
//----------------------------------------------------------------------------
// INPUT: long long IN master_key_number (if you pass <nil> an internal
// check will take place)
//
// RESULT: long long OUT master_code
//
// gets the real master code number from the library
//
// ATTENTION
// first set your master code as default in the McSerialnumber application
// preferences dialog BEFORE you create the library otherwise the resulting
// mastercode can be zero
//----------------------------------------------------------------------------
static long long GetMasterCode (long long inMasterKey);
};
#if __INTEL__
//----------------------------------------------------------------------------
// PARAMETER: IN: StringPtr PASCAL String
// OUT: StringPtr ASNI-String (allocate memory!)
//
//
// RESULT: none
//
// converts a PASCAL string to a ANSI string in place
//
//----------------------------------------------------------------------------
void p2cstr(StringPtr temP);
//----------------------------------------------------------------------------
// PARAMETER: IN: char* ASNI-String
// OUT: char* PASCAL String(allocate memory!)
//
//
// RESULT: none
//
// converts a ANSI string to a PASCAL string in place
//
//----------------------------------------------------------------------------
void c2pstr(char* temP);
#endif
// ATTENTION!
// ----------
// If you incorporate the library in your 68k Application
// allways use the following switches with your Metrowerks IDE:
// 68k Processor: check 4 Byte Ints and 8 Byte Doubles ON
// check Far Data, Far Method Table and Far String Consts ON
// INTEL Windows (95/98/NT) USER
//------------------------------
// you have to convert all input strings from ANSI-C-STRINGS to PASCAL-STRINGS
// first before using the func. CalcNameCode and StripSerialNumber!!
// you can use the included converter functions c2pstr